﻿namespace TestAppSite.Models
{
    using System;
    using System.Text;

    public class UploadFileViewModel
    {
        public string Filename { get; set; }

        public string ContentType { get; set; }

        public string MD5 { get; set; }

        public byte[] Content { get; set; }

        public string AsDataUri()
        {
            return "data:"
                       + this.ContentType
                       + ";base64,"
                       + Convert.ToBase64String(this.Content);
        }

        public string AsText()
        {
            return Encoding.UTF8.GetString(this.Content);
        }
    }
}